
<?php include_once(dirname(__FILE__) . '/../general/head.php'); ?>

<!-- header -->
<?php include_once(dirname(__FILE__) . '/../general/header.php'); ?>

<?php include_once('left.php'); ?>


<div id="page-wrapper">


    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">Danh sách nhân viên</h1>
        </div>
        <!-- /.col-lg-12 -->
    </div>
    <!-- /.row -->
    <div class="row">
        <!--        <div class="col-lg-12">
                    <div class="panel-group" id="accordion">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h4 class="panel-title">
                                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Thống kê</a>
                                </h4>
                            </div>
                            <div id="collapseOne" class="panel-collapse collapse in">
                                <div class="col-lg-6">
                                    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
                                    <script type="text/javascript">
                                        google.load("visualization", "1.0", {'packages': ['corechart']});
                                        google.setOnLoadCallback(drawChart);
                                        function drawChart() {
                                            var data = google.visualization.arrayToDataTable(<?php echo $chartData; ?>);
        
                                            var options = {
                                                title: '',
                                                legend: 'none',
                                                hAxis: {title: '', titleTextStyle: {color: 'red'}}
                                            };
        
                                            var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
                                            chart.draw(data, options);
                                        }
                                    </script>
        
                                    <div id="chart_div"></div>
                                </div>
                                <div class="col-lg-6">
                                    <div class="panel-body">
                                        <table class="table table-bordered table-hover table-striped">
                                            <tr>
                                                <td>Need Improvement</td>
                                                <td><?php echo $ni . ' / ' . count($rows); ?></td>
                                            </tr>
                                            <tr>
                                                <td>Becoming Effective</td>
                                                <td><?php echo $be . ' / ' . count($rows); ?></td>
                                            </tr>
                                            <tr>
                                                <td>Effective</td>
                                                <td><?php echo $ef . ' / ' . count($rows); ?></td>
                                            </tr>
                                            <tr>
                                                <td>High Effective</td>
                                                <td><?php echo $he . ' / ' . count($rows); ?></td>
                                            </tr>
                                            <tr>
                                                <td>Exceptional</td>
                                                <td><?php echo $ex . ' / ' . count($rows); ?></td>
                                            </tr>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>-->

        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    Danh sách
                </div>
                <!-- /.panel-heading -->
                <div class="panel-body">

                    <div class="col-lg-6">
                        Area 
                        <select class="form-control display-inline" name="filter-region" style="width: 150px;">
                            <option value="all">Tất cả</option>
                            <?php foreach ($regions as $eachRegion) { ?>
                                <option value="<?php echo $eachRegion['rsm_code']; ?>" <?php echo ($filterRegion == $eachRegion['rsm_code']) ? 'selected="selected"' : ''; ?>><?php echo $eachRegion['region_name']; ?></option>
                            <?php } ?>
                        </select>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        Nhóm
                        <select class="form-control display-inline" name="filter-title" style="width: 100px;">
                            <option value="all">Tất cả</option>
                            <?php
                            foreach ($titles as $key => $value) {
                                ?>
                                <option value="<?php echo $value; ?>" <?php echo ($filterTitle == $value) ? 'selected="selected"' : ''; ?>><?php echo $key; ?></option>
                            <?php } ?>
                        </select><br><br>
                    </div>


                    <div class="col-lg-12">
                        <?php if ($rows == false || count($rows) == 0) { ?>
                            Hiện tại không có kết quả nào!
                            <br>
                        <?php } else { ?>
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="main-table">
                                    <thead>
                                        <tr>
                                            <th>TL code</th>
                                            <th>SS code</th>
                                            <th>RSM code</th>
                                            <!--<th width="40px">No</th>-->

                                            <th width="90px">Area</th>
                                            <th width="110px">Location</th>
                                            <th width="70px">Mã NV</th>
                                            <th width="50px">Title</th>
                                            <th>Họ và tên</th>

                                            <th width="90px">Start day</th>
                                            <th width="90px">Stop day</th>
                                            <th width="100px">Team leader</th>
                                            <th width="90px">Supervisor</th>
                                            <th width="90px">RSM</th>

                                            <th width="80px">Status</th>
                                            <th width="80px">Status 2</th>
                                            <th>Identity number</th>
                                            <th>Address</th>
                                            <th>Phone</th>
                                            <th>Email</th>
                                            <th>Note</th>
                                            <!--<th>&nbsp;</th>-->
                                        </tr>
                                    </thead>
                                    <tbody>

                                        <?php
                                        $i = 1;
                                        foreach ($rows as $row) {
                                            ?>
                                            <tr>
                                                <td><?php echo $row['teamleader_code']; ?></td>
                                                <td><?php echo $row['supervisor_code']; ?></td>
                                                <td><?php echo $row['rsm_code']; ?></td>
                                                <!--<td><?php echo $i; ?></td>-->

                                                <td><?php echo $regionDic[$row['rsm_code']]; ?></td>
                                                <td><?php echo $row['location']; ?></td>
                                                <td><?php echo $row['code']; ?></td>
                                                <td><?php echo $row['title']; ?></td>
                                                <td><?php echo $row['name']; ?></td>

                                                <td><?php echo $row['starting_day']; ?></td>
                                                <td><?php echo $row['stopping_day']; ?></td>
                                                <td><?php echo $row['teamleader_name']; ?></td>
                                                <td><?php echo $row['supervisor_name']; ?></td>
                                                <td><?php echo $row['rsm_name']; ?></td>

                                                <td><?php echo $row['status']; ?></td>
                                                <td><?php echo $row['status2']; ?></td>
                                                <td><?php echo $row['identity_number']; ?></td>
                                                <td><?php echo $row['address']; ?></td>
                                                <td><?php echo $row['phone']; ?></td>
                                                <td><?php echo $row['email']; ?></td>
                                                <td><?php echo $row['note']; ?></td>
<!--                                                <td>
                                                    <a href="<?php echo site_url(get_folder($loggedUser['title']) . '/users2/edit/' . $row['id']); ?>">
                                                        <img src="<?php echo base_url(); ?>images/edit.png" title="Edit">
                                                    </a>
                                                    <a href="javascript: if(confirm('Bạn có chắc chắn muốn xóa?')){ window.location='<?php echo site_url(get_folder($loggedUser['title']) . '/users2/delete/' . $row['id']); ?>'; }">
                                                        <img src="<?php echo base_url(); ?>images/cross.png" title="Delete">
                                                    </a>
                                                </td>-->
                                            </tr>
                                            <?php
                                            $i++;
                                        }
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                        <?php } ?>
                    </div>
                    <br>
                    
                </div>
                <!-- /.panel-body -->
            </div>
        </div>
    </div>

</div>
<!-- /#page-wrapper -->
<!--<script type="text/javascript" src="<?php echo base_url(); ?>js/filter-region-title.js"></script>-->
<script>
    function search()
    {
        var region = "";
        var title = "";

        $("select[name=filter-region] option:selected").each(function() {
            region = $(this).val();
        });
        $("select[name=filter-title] option:selected").each(function() {
            title = $(this).val();
        });
        window.location = '<?php echo site_url(get_folder($loggedUser['title']) . '/users2/index') ?>' + '/' + region + '/' + title;
    }

    $(document).ready(function() {
        var oTable = $('#main-table').dataTable(
                {
                    "scrollX": true,
                    "sScrollX": "200%",
                    //"bScrollCollapse": true,
                    //"sScrollXInner": "110%",
                    //"bScrollAutoCss": true,
                    "columnDefs": [
                        {
                            "targets": [0],
                            "visible": false,
                            "searchable": false,
                            "orderData": [0, 1]
                        },
                        {
                            "targets": [1],
                            "visible": false,
                            "searchable": false,
                            "orderData": [0, 1]
                        },
                        {
                            "targets": [2],
                            "visible": false,
                            "searchable": false,
                            "orderData": [0, 1]
                        }
                    ]
                }
        );

        $('select[name=filter-region]').change(function() {
            search();
        });

        $('select[name=filter-title]').change(function() {
            search();
        });



    });

</script>
<?php include_once(dirname(__FILE__) . '/../general/footer.php'); ?>